home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
076-100
/
disk_099
/
a-render
/
build_objects
/
bcube.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
4KB
|
141 lines
#include <stdio.h>
main()
{
FILE *fopen(), *fp;
int
polygon_id,
vertice_id,
vlist_id,
object_polygon_count,
object_vertice_count,
object_polygon_vertice_count[41],
object_vertice_list[41] [30];
float
object_vertice_x[41],
object_vertice_y[41],
object_vertice_z[41];
object_polygon_count = 6;
object_vertice_count = 8;
object_vertice_x [1] = -10;
object_vertice_y [1] = -10;
object_vertice_z [1] = 10;
object_vertice_x [2] = -10;
object_vertice_y [2] = 10;
object_vertice_z [2] = 10;
object_vertice_x [3] = 10;
object_vertice_y [3] = 10;
object_vertice_z [3] = 10;
object_vertice_x [4] = 10;
object_vertice_y [4] = -10;
object_vertice_z [4] = 10;
object_vertice_x [5] = -10;
object_vertice_y [5] = -10;
object_vertice_z [5] = -10;
object_vertice_x [6] = -10;
object_vertice_y [6] = 10;
object_vertice_z [6] = -10;
object_vertice_x [7] = 10;
object_vertice_y [7] = 10;
object_vertice_z [7] = -10;
object_vertice_x [8] = 10;
object_vertice_y [8] = -10;
object_vertice_z [8] = -10;
object_polygon_vertice_count [1] = 5;
object_vertice_list [1] [1] = 6;
object_vertice_list [1] [2] = 2;
object_vertice_list [1] [3] = 3;
object_vertice_list [1] [4] = 7;
object_vertice_list [1] [5] = 6;
object_polygon_vertice_count [2] = 5;
object_vertice_list [2] [1] = 7;
object_vertice_list [2] [2] = 3;
object_vertice_list [2] [3] = 4;
object_vertice_list [2] [4] = 8;
object_vertice_list [2] [5] = 7;
object_polygon_vertice_count [3] = 5;
object_vertice_list [3] [1] = 8;
object_vertice_list [3] [2] = 4;
object_vertice_list [3] [3] = 1;
object_vertice_list [3] [4] = 5;
object_vertice_list [3] [5] = 8;
object_polygon_vertice_count [4] = 5;
object_vertice_list [4] [1] = 2;
object_vertice_list [4] [2] = 6;
object_vertice_list [4] [3] = 5;
object_vertice_list [4] [4] = 1;
object_vertice_list [4] [5] = 2;
object_polygon_vertice_count [5] = 5;
object_vertice_list [5] [1] = 6;
object_vertice_list [5] [2] = 7;
object_vertice_list [5] [3] = 8;
object_vertice_list [5] [4] = 5;
object_vertice_list [5] [5] = 6;
object_polygon_vertice_count [6] = 5;
object_vertice_list [6] [1] = 4;
object_vertice_list [6] [2] = 3;
object_vertice_list [6] [3] = 2;
object_vertice_list [6] [4] = 1;
object_vertice_list [6] [5] = 4;
if ((fp = fopen("cube.obj","w")) == 0) {
printf("Couldn't open cube.obj file for write\n");
exit();
}
fprintf(fp,"1 1 3 %d %d",
object_polygon_count,
object_vertice_count);
for (vertice_id=1;
vertice_id <= object_vertice_count; vertice_id++)
{
fprintf(fp," %f %f %f",
object_vertice_x [vertice_id],
object_vertice_y [vertice_id],
object_vertice_z [vertice_id]);
}
for (polygon_id=1;
polygon_id <= object_polygon_count; polygon_id++)
{
fprintf(fp," %d",
object_polygon_vertice_count [polygon_id]);
for (vlist_id=1;
vlist_id <= object_polygon_vertice_count [polygon_id];
vlist_id++)
{
fprintf(fp," %d",
object_vertice_list [polygon_id] [vlist_id]);
}
}
printf("objects.dta written\n");
fclose(fp);
printf("closed\n");
}